<?php

/**
 * 首页
 * @copyright (c) 2013, Mr.Wang
 * @author Mr.Wang <281762391@qq.com>
 */
class CaiAction extends UserAction {

    public $model;

    public function _initialize() {
        parent::_initialize();
        $this->model = D("Cai");
    }

    function _filter(&$map) {
        $map['cai_owner_id'] = session("uid");
    }

    public function _before_insert() {
        $this->_before_update();
    }

    public function _before_update() {
        if ($this->has_upload()) {
            $savePath           = "/Public/Uploads/" . date("Ymd") . "/";
            $file               = $this->upload($savePath);
            $_POST['cai_thumb'] = $savePath . $file['cai_thumb']['savename'];
        }
    }

}
